package br.urca.impl;

import java.util.List;

import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;

import br.urca.dao.CursoDAO;
import br.urca.model.Curso;

@Transactional
public class JPACursoDAO implements CursoDAO {
	
	private EntityManager manager;
	
	public JPACursoDAO() {
		this(null);
	}
	
	@Inject
	public JPACursoDAO(EntityManager manager) {
		this.manager = manager;
	}

	@Override
	public List<Curso> todos() {
		return this.manager.createQuery("SELECT c FROM Curso c", Curso.class)
				.getResultList();
	}

}
